using System;
using System.Collections.Generic;

namespace Caramel
{
	public class DelegateComparer<T> : IEqualityComparer<T>
	{
		private Func<T, T, bool> _comparer;

		public DelegateComparer(Func<T, T, bool> comparer)
		{
			_comparer = comparer;
		}

		#region IEqualityComparer<T> Members

		public bool Equals(T x, T y)
		{
			return _comparer(x, y);
		}

		public int GetHashCode(T x)
		{
			// Ignore the hash code so we fall into the equals
			return -1;
		}

		#endregion
	}
}
